package linwen.wang.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class MetaHandler implements MetaObjectHandler {
 /**
  * 新增数据执行
  * @param metaObject
  */
 @Override
 public void insertFill(MetaObject metaObject) {
  this.setFieldValByName("createdTime", new Date(), metaObject);
  this.setFieldValByName("updatedTime", new Date(), metaObject);
  this.setFieldValByName("version","1",metaObject);
  this.setFieldValByName("deleted","N",metaObject);
 }
 /**
  * 更新数据执行
  * @param metaObject
  */
 @Override
 public void updateFill(MetaObject metaObject) {
  this.setFieldValByName("updatedTime", new Date(), metaObject);
 }
}
